package com.aiguigu.LeetCode;

import java.util.HashMap;

public class lenghtOfLonGetSunstring {
    public static void main(String[] args) {
            String s ="acvfgaabbcnb";
        int i = test_(s);
        System.out.println(i);
    }

    public static int test_(String s){
      if (s.length() == 0) return 0;
      HashMap<Character, Integer>map = new HashMap<>();
      int max=0;
      int left = 0;
      for (int i=0;i<s.length();i++){
          if (map.containsKey(s.charAt(i))){
              left = Math.max(left,map.get(s.charAt(i))+1);
          }
          map.put(s.charAt(i),i);
          max = Math.max(max,i-left+1);
      }
     return max;
    }
}
